package breakthrough;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class GameManager
{
	public static void showLoggedBestBoards()
	{
		char [][] boardTab = new char[8][8];
		try {
		BufferedReader bf = new BufferedReader(new FileReader("bestBoards.log"));
		
		String line;
		int i;
		
			while ((line = bf.readLine()) != null)
			{
				i = 0;
				for (int row = 0; row < Board.BOARD_WIDTH; row++)
				{
					for (int col = 0; col < Board.BOARD_HEIGTH; col++)
					{
						boardTab[row][col] = line.charAt(i++);
					}
				}
				
				// Create, evaluate and show board
				Board board = new Board(boardTab, null);
				BoardEvaluator.evaluateBoard(board, new Player(Player.BLUE_PLAYER), new Player(Player.BLUE_PLAYER));
				board.show();
			}
			bf.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void main(String [] args)
	{
		/*Move m = new Move(new PawnPosition(6, 0), new PawnPosition(5, 0));
		
		System.out.println(m);
		System.out.println(m.getSourcePosition());
		System.out.println(m.getDestinationPosition());
		System.out.println("Valid move: " + m.isValidMove());*/
		
		/*System.out.println("--- b1 ---");
		Board b1 = new Board();
		BoardEvaluator.evaluateBoard(b1, new Player(Player.BLUE_PLAYER));
		b1.show();
		System.out.println("--- b2 ---");
		Board b2 = MoveManager.makeNewBoard(b1.getBoardTable(), new PawnPosition(1, 1), new PawnPosition(2, 0));
		BoardEvaluator.evaluateBoard(b2, new Player(Player.BLUE_PLAYER));
		b2.show();
		System.out.println("--- succesors of b1 ---");
		ArrayList<Board> succ = MoveManager.getPossibleBoards(b1, new Player(Player.BLUE_PLAYER));
		System.out.println("b2 successors count = " + succ.size());
		
		for (int i = 0; i < succ.size(); i++)
		{
			BoardEvaluator.evaluateBoard(succ.get(i), new Player(Player.BLUE_PLAYER));
			System.out.println("Successeur #" + i);
			succ.get(i).show();
		}*/
		
		showLoggedBestBoards();
		
	}
}
